// const base_url = "https://example.com"
const base_url = "https://travel.gxucreate.com/travel"

let $request = async (options) => {
  return new Promise((resolve, reject) => {
    wx.request({
      url: base_url + options.url,
      data: options.data || {},
      method: options.method || 'GET',
      header: {
        'content-type': options.header || 'application/x-www-form-urlencoded'
      },
      success: res => {
        if (res.statusCode == 200 || res.data.status) {
          resolve(res);
        }
        else {
          reject(res.data.err);
        }
      },
      fail: err => {
        reject(err);
      }
    })
  })
}
export const request = $request;